#ifndef __LOADCONFIG_H__
#define __LOADCONFIG_H__

#include <map>
#include <string>
#include <fstream>
#define CONFIG_PATH "server.config"
using std::map;
using std::string;
using std::ifstream;

class LoadConfig{
public:
    static map<string,string> loadConfig(){
        map<string,string> config;
        ifstream ifs{CONFIG_PATH};
        string line;
        while(std::getline(ifs,line)){
            if(line.empty() || line[0]=='#') continue;
            auto pos = line.find('=');
            if(pos==string::npos) continue;
            string name = line.substr(0,pos);
            string val = line.substr(pos+1);
            config[name]=val;
        }
        return config;
    }
};

#endif